package com.sskj.xcs;


import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;

/**
 * @Author: Like
 * @Date: 2023/11/28 14:49
 * @Description:
 */
public class Demo1 {
    public static void main(String[] args) throws Exception{

        String url = "http://iot.shslgc.com:8083/gateway/luban/xcsModel/findByFieId?fileId=xcsx.2.13.1.1";
        HttpURLConnection conn = (HttpURLConnection) new URL(url).openConnection();
        conn.setRequestMethod("GET");
        conn.setRequestProperty("Authorization","Bearer eyJhbGciOiJIUzUxMiJ9.eyJleHAiOjE3MDEyMjMwOTEsInNlc3Npb25JZCI6ImFkbWluXzRfYzhlMmJmZGJkZDdmNGFlNDg2N2M2MzAwMzc0MzZkNGYiLCJDcmVhdGVkVGltZSI6MTcwMTE1MTA5MTk1N30.9Gdy19Joms3B7tmZ_hE-hbGN230iWye_Y26c4YTGI9HEjOIGmG4ZXGAXBwrCCKC4ddpMH71V-SfWs5tEasMAFQ");

        // 获取响应
        InputStream in = conn.getInputStream();
        BufferedReader br = new BufferedReader(new InputStreamReader(in));
        String line;
        StringBuilder response = new StringBuilder();
        while ((line = br.readLine()) != null) {
            response.append(line);
        }
        br.close();
        in.close();

        // 解析JSON数据
        JSONObject jsonObject = JSON.parseObject(response.toString());
        JSONObject data = jsonObject.getJSONObject("data");
        JSONArray imgUrls = data.getJSONArray("imgUrls");
        String imgUrl = imgUrls.get(0).toString();
        System.out.println(imgUrl);

    }

}